# - Locate the GNU Guile library

include(CheckIncludeFile)
include(CheckLibraryExists)

MACRO(FIND_GUILE GUILE_LDFLAGS)
  CHECK_INCLUDE_FILE("libguile.h" HAS_LIBGUILE_H)
  if(HAS_LIBGUILE_H)
    # Do we have -lguile
    CHECK_LIBRARY_EXISTS(guile scm_init_guile "" HAS_LIB_GUILE)
    if(HAS_LIB_GUILE)
      set(GUILE_LDFLAGS -lguile)
    endif(HAS_LIB_GUILE)
  endif(HAS_LIBGUILE_H)

  if(NOT HAS_LIB_GUILE)
    message(FATAL_ERROR "guile library not found")
  endif(NOT HAS_LIB_GUILE)
ENDMACRO(FIND_GUILE)

